<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<!--User: xulf Date: 2018/11/29 Time: 14:32-->
<head th:include="include/includebase"></head>
<link th:href="@{/css/change/changeForm/changeOrderTable.css}" rel="stylesheet"/>
<meta charset="UTF-8">
<title>相关性</title>
</head>
<body>
<div class="form-group">
    <button type="button"class="btn btn-primary"onclick="doReturn();" style="float: right">返回上一步</button>
</div>
<h4><i class="fa fa-minus-square" aria-hidden="true">相关性</i></h4>
<div class="panel-body" style="padding-bottom: 0;">
    <form class="form-inline" role="form" style="float: left; width: 100%;margin-left: 20px;" method="get"
          id="relevanceChangeData">
        <input type="hidden" id="orderId" th:value="${orderId}">
    </form>
</div>
<div class="panel-body" style="padding:0px;">
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="content col-lg-12 col-md-12" style="padding:0px;">
                <table class="table table-striped tableNormalStyle" id="relevance_table">
                </table>
            </div>
        </div>
    </div>
</div>
<script th:inline="javascript">
    $(document).ready((function () {
        initTable();
    }))


    function initTable() {
        var projectPuid = $("#project", window.top.document).val();
        var $table = $("#relevance_table");
        var orderId = $("#orderId").val();
        var column = [];
        column.push({
            field: '',
            title: '序号',
            align: 'center',
            Width: 50,
            formatter: function (value, row, index) {
                var options = $table.bootstrapTable('getOptions');
                return options.pageSize * (options.pageNumber - 1) + index + 1;

            }
        });
        column.push({
            field: 'headDesc',
            title: '变更类型',
            align: 'center',
            Width: 50
        });
        column.push({
            field: 'rbRelevance',
            title: '相关性',
            align: 'center',
            Width: 50
        });
        column.push({
            field: 'rbRelevanceDesc',
            title: '相关性描述',
            align: 'center',
            Width: 50
        });
        column.push({
            field: 'rbRelevanceCode',
            title: '相关性代码',
            align: 'center',
            Width: 50
        });
        $table.bootstrapTable({
            url: "../../../vwo/getRelevance?orderChangeId="+orderId,
            method: 'GET',
            dataType: 'json',
            height: $(window.parent.document).find("#wrapper").height() - 150,
            width: $(window).width(),
            formId: 'ebomChangeData',
            undefinedText: "",//当数据为 undefined 时显示的字符
            pagination: false,
            columns: column,
            toolbar: "#toolbar",
            sortOrder: "asc",                   //排序方式
            clickToSelect: true,// 单击某一行的时候选中某一条记录
            showColumns: false, //是否显示所有的列
            showToggle: false,                   //是否显示详细视图和列表视图的切换按钮
            showRefresh: false,                  //是否显示刷新按钮
            toolbars: [
                {
                    text: '删除',
                    iconCls: 'glyphicon glyphicon-remove',
                    handler: function () {
                        var url = "vwo/deleteChangeRelevance";
                        $.ajax({
                            url: "../../../privilege/write?url=" + url,
                            type: "GET",
                            success: function (result) {
                                if (!result.success) {
                                    window.Ewin.alert({message: result.errMsg});
                                    return false;
                                }
                                else {
                                    window.Ewin.confirm({title: '提示', message: '确定要删除数据吗?', width: 500}).on(function (e) {
                                        if (e) {
                                            $.ajax({
                                                type: "POST",
                                                url: "../../../vwo/deleteChangeRelevance?orderChangeId="+orderId,
                                                success: function (result) {
                                                    if (result.status) {
                                                        layer.msg('删除成功', {icon: 1, time: 2000})
                                                        window.location.reload();
                                                    } else if (!result.status) {
                                                        window.Ewin.alert({message: result.errMsg});
                                                    }
                                                    $table.bootstrapTable("refresh");
                                                },
                                                error: function (info) {
                                                    window.Ewin.alert({message: "操作失败:" + info.status});
                                                }
                                            })
                                        }
                                    });
                                }
                            }
                        })
                    }
                },
            ]
        });
    }
    function doReturn() {
        window.location.href="javascript:history.go(-1);"
    }
</script>
</body>
</html>